package com.littlebee.storysuper.utils;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by liaoyong on 26/11/2017.
 */

public class ThreadPoolManager {
    private ExecutorService service;
    private static ThreadPoolManager manager;

    private ThreadPoolManager() {
        int num = Runtime.getRuntime().availableProcessors();
        this.service = Executors.newFixedThreadPool(num * 2);
    }
    public static ThreadPoolManager getInstance() {
        if(manager == null) {
            manager = new ThreadPoolManager();
        }
        return manager;
    }

    public void addTask(Runnable runnable) {
        this.service.submit(runnable);
    }
}
